package lab02.Test06;

/**
 * Created by Administrator on 2017/10/15.
 */
public class Triangle {
    //属性:边1，边2，边3
    double side1;
   double  side2;
   double  side3;
   double c;
   double area;
   boolean boo;
    //行为：周长、面积以及修改三个边
   public Triangle(double a,double b,double c){side1=a;side2=b;side3=c;
   if(a+b>c&a+c>b&b+c>a)
   {
       boo=true;
   }
   else{
       boo=false;
   }
   }
    double C(){return side1+side2+side3;}
    public double Area(){
        if(boo){double p=(side1+side2+side3)/2.0;
    area=Math.sqrt(p*(p-side1)*(p-side2)*(p-side3));
    return area;}
    else{
            System.out.println("不是一个三角形，不能计算面积");
            return 0;
        }
    }
  public  void set123(double a,double b,double c){
        side1=a;side2=b;side3=c;
        if((a+b>c&a+c>b&b+c>a)&(a-b<c&a-c<b&b-c<a)){
            boo=true;
        }
       else
           {boo=false;}
  }

    public static void main(String[] args) {
        Triangle area1=new Triangle(3,4,5);
        System.out.println("面积为："+area1.Area());
        Triangle c1=new Triangle(6,8,10);
        System.out.println("周长为："+c1.C());
    }
    }

